<include file="Common/common" />

<body>
	
	<div class="layui-tab-item layui-show">
		<div class="layui-main">
			<fieldset class="layui-elem-field layui-field-title" style="margin-top: 20px;">
			  	<legend style="color: rgb(240,222,112);">购买</legend>
			</fieldset>

			<div style="overflow-x: auto;">
				<table class="layui-table" id="buy-list" style="color: rgb(240,222,112);">
					<thead>
							<tr style="background: rgb(57,61,73)">
								<th>编号</th>
								<th>积分</th>
								<th>出售用户</th>
								<th>操作</th>
							</tr> 
						</thead>
						<tbody>
							<foreach name="buyList" item="vo">
								<tr style="background: #7d7d7d;color:rgb(240,222,112);">
									<td>{$vo['id']}</td>
									<td>{$vo['num']}</td>
									<td>{$vo['sell_account']}</td>
									<td>
										<button  style="color: rgb(240,222,112);background: rgb(57,61,73);font-size: 16px"  <if condition="$p gt 1 or $vo['sell_uid'] eq $uid ">class="layui-btn layui-btn-disabled"
										<if condition="$p gt 1">title="有订单未完成，请先完成订单"<else/>title="无法购买自己挂售的订单"</if>
										 <else /> class="layui-btn" onclick="func_buy(this,{$vo['id']})"</if> >购买</button>
									</td>
								</tr>
							</foreach>
						</tbody>
				</table>
			</div>
			<div class="green-black">{$page}</div>

		</div>
	</div>
</body>

<script type="text/javascript">
	// 购买
	function func_buy(obj,id){
		layer.confirm('点击购买确认后请到购买报表上传交易凭证',{offset:'none'},function(index){
			$.ajax({
	            type: "post",
	            url: "{:U('Order/ctrl_buy')}",
	            data: {id:id},
	            dataType: "json",
	            success: function(rtJson){
                    layer.msg('<span style="color: rgb(240,222,112);">'+rtJson.msg+'</span>');
	            	if (rtJson.code == 1) {
	            		setTimeout(function(){location.href = "{:U('Order/buylist')}";}, 1000);
	            	}
	            	
            		
	            }
	        });
		});
	}
</script>
<include file="Common/footer" />